#include "ecb/benchmarks/mpb/PeakFunctionCone.h"

#include "ecb/base/Math.h""
#include <math.h>

namespace ecb {
    namespace mpb {

        PeakFunctionCone::PeakFunctionCone() { }

        PeakFunctionCone::~PeakFunctionCone() { }

        scalar PeakFunctionCone::f(const std::vector<scalar>& x, const Matrix2D& peaks, int peakIndex) {
            scalar dummy = Math::Pow2(x[0] - peaks[peakIndex][0]);
            for (size_t j = 1; j < x.size(); j++) {
                dummy += Math::Pow2(x[j] - peaks[peakIndex][j]);
            }
            return peaks[peakIndex][x.size() + 1] -
                    (peaks[peakIndex][x.size()] * sqrt(dummy));

        }

        std::string PeakFunctionCone::toString() const {
            return "PeakFunctionCone";
        }

    }
}
